﻿<?xml version="1.0" encoding="utf-8"?>
<Window
    x:Class="Automator.Windows.NewTaskWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:toolkit="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit.Extended"
    Title="New Task"
    Height="400"
    Width="600"
    WindowStartupLocation="CenterOwner"
    ShowInTaskbar="False"
    ShowActivated="True"
    Loaded="Window_Loaded"
    MinHeight="200"
    MinWidth="350" xmlns:core="clr-namespace:Automator.Tasks.Core;assembly=Automator.Tasks.Core"
    ResizeMode="CanResize"
    Background="{x:Static SystemColors.ControlBrush}">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition
                Height="Auto" />
            <RowDefinition
                Height="*" />
            <RowDefinition
                Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition
                Width="*" />
            <ColumnDefinition
                Width="Auto" />
        </Grid.ColumnDefinitions>
        <StackPanel
            Grid.Row="0"
            Grid.Column="1"
            HorizontalAlignment="Right">
            <toolkit:WatermarkTextBox
                x:Name="edtFilter"
                Margin="8,8,2,8"
                VerticalContentAlignment="Center"
                Padding="4"
                Width="200"
                MinHeight="24"
                TextChanged="EdtFilter_TextChanged"
                Watermark="Type To Search..."></toolkit:WatermarkTextBox>
        </StackPanel>
        <ListView
            Grid.Row="1"
            Grid.ColumnSpan="2"
            x:Name="lstTasks"
            MouseDoubleClick="lstTasks_MouseDoubleClick"
            SelectionMode="Single">
            <ListView.GroupStyle>
                <GroupStyle>
                    <GroupStyle.ContainerStyle>
                        <Style
                            TargetType="{x:Type GroupItem}">
                            <Setter
                                Property="Margin"
                                Value="0,0,0,5" />
                            <Setter
                                Property="Template">
                                <Setter.Value>
                                    <ControlTemplate
                                        TargetType="{x:Type GroupItem}">
                                        <Expander
                                            IsExpanded="True">
                                            <Expander.Header>
                                                <StackPanel
                                                    Margin="8,2,2,2"
                                                    Orientation="Horizontal"
                                                    VerticalAlignment="Center">
                                                    <TextBlock
                                                        FontWeight="Black"
                                                        Text="{Binding Path=Name}"
                                                        Margin="5,0,0,0"
                                                        Width="300"
                                                        VerticalAlignment="Center" />
                                                </StackPanel>
                                            </Expander.Header>
                                            <Expander.Content>
                                                <ItemsPresenter />
                                            </Expander.Content>
                                        </Expander>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </GroupStyle.ContainerStyle>
                </GroupStyle>
            </ListView.GroupStyle>
            <ListView.View>
                <GridView>
                    <GridViewColumn>
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <Image
                                    Width="32"
                                    Height="32"
                                    Source="{Binding TaskImage}"
                                    Margin="4,4,16,4"
                                    VerticalAlignment="Center" />
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    <GridViewColumn
                        Header="Title">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock
                                    Text="{Binding Path=Title}"
                                    VerticalAlignment="Center"
                                    TextWrapping="Wrap"
                                    FontWeight="Bold"
                                    FontSize="12" />
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    <GridViewColumn
                        Header="Description">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock
                                    Text="{Binding Path=Description}"
                                    VerticalAlignment="Center"
                                    TextWrapping="Wrap" />
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    <GridViewColumn
                        Header="Assembly"
                        DisplayMemberBinding="{Binding Path=AssemblyFileName}" />
                    <GridViewColumn
                        Header="Version"
                        DisplayMemberBinding="{Binding Path=AssemblyFileVersion}" />
                </GridView>
            </ListView.View>
        </ListView>
        <StackPanel
            Orientation="Horizontal"
            Grid.Row="2"
            Grid.Column="1"
            HorizontalAlignment="Right">
            <Button
                Name="btnAdd"
                Content="Add"
                Padding="16,4,16,4"
                Margin="4"
                Click="BtnAdd_Click" />
            <Button
                Name="btnCancel"
                Content="Cancel"
                Padding="16,4,16,4"
                Margin="4"
                IsCancel="True" />
        </StackPanel>
    </Grid>
</Window>